Perception of power quality disturbances using Fourier, Short-Time Fourier, continuous and discrete wavelet transforms

Electric power utilities must ensure a consistent and undisturbed supply of power, with the voltage levels adhering to specified ranges. Any deviation from these supply specifications can lead to malfunctions in equipment. Monitoring the quality of supplied power is crucial to minimize the impact of fluctuations in voltage. Variations in voltage or current from their ideal values are referred to as "power quality (PQ) disturbances," highlighting the need for vigilant monitoring and management. Signal processing methods are widely used for power system applications which include understanding of voltage disturbance signals and used for retrieval of signal information from the signals Different signal processing methods are used for extracting information about a signal. The method of Fourier analysis involves application of Fourier transform giving frequency information. The method of Short-Time Fourier analysis involves application of Short-Time Fourier transform (STFT) giving time–frequency information. The method of continuous wavelet analysis involves application of Continuous Wavelet transform (CWT) giving signal information in terms of scale and time where frequency is inversely related to scale. The method of discrete wavelet analysis involves application of Discrete Wavelet transform (DWT) giving signal information in terms of approximations and details where approximations and details are low and high frequency representation of original signal. In this paper, an attempt is made to perceive power quality disturbances in MATLAB using Fourier, Short-Time Fourier, Continuous Wavelet and Discrete Wavelet Transforms. Proper understanding of the signals can be possible by transforming the signals into different domains. An emphasis on application of signal processing techniques can be laid for power quality studies. The paper compares the results of each transform using MATLAB-based visualizations. The discussion covers the advantages and disadvantages of each technique, providing valuable insights into the interpretation of power quality disturbances. As the paper delves into the complexities of each method, it takes the reader on a journey of signal processing complexities, culminating in a nuanced understanding of power quality disturbances and their representations across various domains. The outcomes of this research, elucidated through energy values, 3D plots, and comparative analyses, contribute to a comprehensive understanding of power quality disturbances. The findings not only traverse theoretical domains but also find practical utility in real-world scenarios.

The newly developed use of DWT for signal decomposition into multiresolution components stands out as a noteworthy contribution.The study not only finds low and high-frequency representations but also excels at catching transitions and abrupt shifts within the signals by offering a deep examination of approximations and details.This unique method overcomes the limitations of previous methods by providing a more sophisticated knowledge of power quality disturbances and their representations across domains.The results of this study provide a refined and thorough approach for power quality assessment, which adds significant value to the field of power system analysis.In order to promote improvements in power system stability and reliability, future research will be guided by the comparative analysis provided in this work when choosing suitable signal processing algorithms based on particular characteristics of power quality disturbances.

Power quality disturbance signals
Electric power utilities provide voltage that often experiences undesirable variations such as transients, sags, swells, interruptions, voltage imbalances, DC offsets, harmonics, noise, and fluctuations.Ensuring a constant and stable voltage supply is crucial for maintaining the quality of power, and all these variations fall within the overarching category of power quality disturbances.The analysis of disturbance signals plays a vital role in identifying and implementing appropriate preventive measures.
To analyze various voltage variations and proactively address abrupt changes in the connected load, signal processing techniques prove instrumental.The detection of voltage signal variations is crucial for implementing effective preventive measures.Transforming signals, which are temporal functions, into the time and frequency domain facilitates a more insightful interpretation of the original signal in the time domain.The signals under consideration encompass sag, swell, interruption, transient, harmonics, fluctuations, and flicker, alongside a sinusoidal signal utilized as a reference.Each of these signals manifests a discernible deviation, either in magnitude or frequency, from the pristine sinusoidal form of voltage over specific durations.The paper delineates the definitions of power quality disturbance signals and elucidates the application of Fourier transform, short-time Fourier transform, continuous wavelet transform, and discrete wavelet transforms to power quality disturbances.The visual identification of disturbance signals through diverse transforms in MATLAB streamlines the categorization of disturbances, thereby enhancing power quality evaluation.

Generation of power quality disturbance signals
Mathematical modelling is carried out by parametric equations and the equations used for developing MAT-LAB code for different disturbance signal generation are presented with the description of various parameters governing the equations.In order to apply signal processing methods, the basic step is to generate the signals.Due to changes in voltage in terms of any or all of magnitude, duration and frequency, there will be a deviation from pure sinusoidal form.Certain parameters define signals.Disturbances create signals, which are defined by waveforms with a fundamental frequency of 50Hz and a voltage magnitude of 1 per unit (pu) lasting 0.25 s.The term "pu" refers to a dimensionless number that represents measurements per unit.
Modeling power quality disturbances is critical in assessing power quality.Analyzing voltage disturbance waveforms leads to the discovery of power quality events.In 23 , a framework based on numerical models is used to generate various power quality waveforms.The term A represents the maximum value of the supply voltage V (t).Equation (1) represents pure sinusoidal supply voltage without any distortions with amplitude A and is given as: In all the equations defined for transient, interruption, sag and swell the terms, u(t 1 ), u(t 2 ), u(t − t 1 ) and u(t − t 2 ) represent amplitude of unit step functions defined for period's t 1 , t 2 , duration (t − t 1 ) and duration (t − t 2 ) respectively.For voltage interruption, sag and swell the duration (t 2 − t 1 ) is between T and 9T , where T represents time period of the sinusoidal voltage signal.Values of t 1 and t 2 are 0.08 and 0.16 s and t 2 is greater than t 1 .The equations dictating each power quality disturbance are contingent on controlled parameters.
Choice of values of various parameters taken in literature depends on the necessity that generated signals must depict the actual conditions in a controlled manner and definitions given by IEEE must not be deviated.It is very important to choose different parameter values in such a manner that the waveforms are according to their standard definitions.Different simulation tools used for power system analysis are mentioned in 24 .

Transient
The term transient refers to an undesirable and short event.It can be a unidirectional impulse of positive or negative polarity.It can also be an oscillatory wave with damping and first peak occurring in either polarity 2 .Transients are mainly due to lightning strikes on transmission lines resulting in dangerously high potential differences.
Oscillatory transients are numerically modelled 15 by Eq. (2) as: Angular frequencies of supply voltage and transients are ω = 2πf and ω n = 2πf n .The terms α, τ and f n represent magnitude, settling time and oscillatory frequency respectively for the transient.In the equations for transients, the ranges taken for α, τ and f n are 0.1 to 0.8, 0.008 to 0.04 s and 300 to 900 Hz respectively.The transient disturbance is defined for period t 1 as: (1)  3).The magnitude of voltage varies from 1.381 to − 1.972 pu for a very short duration.

Interruption
An interruption is identified by the loss of supply voltage or load current.Specifically, it happens when the supply voltage or load current drops to less than 0.1 per unit (pu) and lasts for no more than 1 min 2 .Interruption is numerically modelled as in 15 in Eq. ( 4).
Using MATLAB to simulate Eq. ( 4), Fig. 2 displays a waveform with an interruption, illustrating a complete loss of voltage for a specific duration.The range for the parameter α is 0.9 to 1.   www.nature.com/scientificreports/Voltage sag Sag is decrease in rms voltage from 0.1 pu and 0.9 pu for duration of 0.5 cycles to 1 min 2 .Voltage sag is numerically modelled as in 15 is given by Eq. ( 5).
Figure 3 depicts a voltage sag, obtained through the simulation of Eq. ( 5) in MATLAB.
The range for the parameter α is 0.1 to 0.9.

Voltage swell
Swell is characterized by an increase in root mean square (rms) voltage beyond 1.1 per unit (pu) up to 1.8 pu, lasting from 0.5 cycles to 1 min 2 .Voltage swell is numerically modelled as in 15 is given by Eq. ( 6).
Figure 4 illustrates a voltage swell, achieved through the simulation of Eq. ( 6) in MATLAB.This graph signifies a sudden and temporary rise in voltage for a specific duration.
The range for the parameter α is 0.1 to 0.9.

Harmonics
Harmonics fall within the realm of waveform distortion, representing voltages or currents with integer multiples of the fundamental frequency 2 .Harmonics are produced by loads having nonlinear characteristics and are numerically modelled as in 15 and given by Eq. (7).
The magnitude of nth order harmonic is α n and is summation of amplitudes of harmonic components.
By simulating Eq. ( 8) for harmonics, harmonics signal is obtained as depicted in Fig. 5.

Fluctuations
Fluctuations are systematic variations of envelope of voltage.There will be random changes and magnitude of voltage does not exceed 0.95 pu to 1.05 pu 2 .
Terms a and b are controlling parameters representing magnitude and integer multiple of frequency with ranges given as 0.1 ≤ a ≤ 0.2 and 0.4 ≤ b ≤ 0.6 .Waveform of fluctuations is shown in Fig. 6, obtained in MATLAB by simulating Eq. ( 9).

Flicker
Flicker is the consequence of voltage fluctuations affecting lighting intensity 2 .The voltage signal, as expressed in terms of flicker 25 , is defined by Eq. (10).
A 1 , ω 1 and 1 correspond to amplitude, angular frequency and phase angle of fundamental component of voltage.A fi , ω fi and fi correspond to amplitude, angular frequency and phase angle of flicker component of voltage.The term I refers to number of components of flicker.
In 25 , general procedure to get severity of flicker level is described in terms of several blocks involving extraction of fundamental signal, voltage envelope from a power signal fed as input and with an output of "instantaneous flicker level".This process involves spectral analysis to identify flicker components.Flicker waveform is shown in Fig. 7 and is generated in MATLAB.
The generated power quality disturbances contain information about disturbance in terms of magnitude and duration.Preventive measures are to be taken for avoiding the disturbances.www.nature.com/scientificreports/It can be concluded that Fourier transform is effective for the signals whose frequency content is same at every point of time and determine existing frequency.But no adequate information is obtained related to sudden changes in voltage which are prone in practical point of view.The changes occurring in the signal are not localized in time i.e. the time at which these frequency components exist cannot be determined using Fourier transform.Information about frequency is absent in time domain and information about time is absent in frequency domain.www.nature.com/scientificreports/frequency variations as a function of time with representing power at any instant by a color.The mathematical equation of STFT is given by Eq. ( 12).
Signal to be transformed, window function and time index are represented by x(t), ω(τ ) and τ .X(τ , ω) is the Fourier transform of x(t)ω(t − τ ) and represents a complex function.The complex values represent phase and magnitude of signal over time and frequency.'Hamming window' is used for analysis of PQ signals.Figures 16,  17 To depict the change in signal representation for changing window size, an interruption signal is considered as an example.Figure 24 shows the variation of an interruption signal, for different widths of window segments.Precise window size is necessary for STFT i.e. window size must neither be too small nor too large such that information is lost in representation.Blue segments show low power levels and broad yellow color in the spectrogram shows signal power spread across the range of frequencies.As window size is increased, good frequency resolution is possible by loosing time information and as window size is narrowed down, good time resolution is possible by loosing frequency information.Selection of window size is necessary for balancing both resolutions.By using STFT, frequency versus time information can be obtained by proper choice of window width.The perception of signal changes upon changing the window size.This has initiated for wavelet transform based methods.

Application of continuous wavelet transform (CWT)
The signals which are a function of time can be transformed into another domain of time and frequency for better interpretation of the original signal in time domain.Continuous wavelet transform, a mathematical transform technique, is used for analysis of signals.Detection of changes in signals using continuous wavelet transform is    Scaling and translating a mother wavelet ψ give a family ψ τ ,s of 'wavelet daughters' given by Eq. ( 13) 28 .The correlation between the voltage variation signals and 'wavelet daughters' also termed as template functions, gives information about the disturbance in the signal.This is due to the comparison of template functions against the voltage variation signals.www.nature.com/scientificreports/CWT with respect to the wavelet ψ is W x,ψ (τ , s) , given by Eq. ( 14) is the wavelet transform by mapping the signal in time domain x(t) into a function of s and τ giving information simultaneously on time and frequency, where scale is related inversely to frequency 28 .Position of wavelet in time domain is given by τ and position in frequency domain is given by s.

Continuous wavelet analysis
It can be established that by using CWT, time domain functions can be mapped into time and frequency domain.Sum over all time of the signal multiplied by scaled, shifted versions of the wavelet function ψ defines CWT and coefficients as function of scale and position are obtained 27 .

Continuous wavelet analysis using MATLAB graphical interface
Continuous Wavelet Analysis (CWT) is performed using MATLAB, leveraging both command-line functionality and the graphical interface for a comprehensive exploration of power quality disturbance signals 29,30 .MATLAB's graphical interface provides an intuitive platform for users to interactively analyze and visualize CWT results.The combination of command-line scripts and graphical tools enhances the accessibility and user-friendliness of the analysis process.MATLAB's graphical interface facilitates the dynamic exploration of CWT results by allowing users to interactively adjust scale and time parameters 31 .This interactivity empowers researchers to fine-tune the analysis, enabling a detailed examination of disturbances at different scales and time intervals 32 .The graphical representation of CWT coefficients as a function of scale and time offers a unique perspective on signal variations.MATLAB's plotting capabilities enable the creation of coefficient line plots, aiding in the identification of hidden patterns that might not be immediately apparent in the original signals.MATLAB's graphical interface provides a wide selection of wavelets for CWT analysis.Researchers can easily experiment with various mother wavelets, including Morse, Morlet, and bump wavelets, to identify the most suitable wavelet for capturing specific features in power quality disturbances 33,34 .The inclusion of 3D plots representing disturbance signals with time, scale, and coefficient values enhances the visual interpretation of CWT results.These plots, generated through MATLAB's graphical interface, offer a holistic view of energy distribution across different scales and times 35,36 .Researchers can utilize MATLAB's graphical interface to obtain quantitative insights into the energy levels of CWT coefficients.The tabular representation of energy values for different scales (1 and 64) aids in expressing signal strength in terms of coefficient energy 37 .The integration of MATLAB's graphical interface into the CWT analysis process not only simplifies the workflow but also contributes to the enhanced interpretability of power quality disturbance signals.Wavelet toolbox is one of powerful graphical interfacing tools in MATLAB for power quality 38 .In 39 , sag and swell are analyzed in a transmission system employing a suitable compensator.Harmonics are analyzed using STFT in 40 using different window lengths and in 41 , statistical features are extracted from PQ signals.Wavelet toolbox main menu can be opened in a new window and continuous Wavelet 1-D graphical tool is selected.The signal can be loaded directly in ". mat" format or MAT-files which refers to files readable by MATLAB.The signal can also be imported from workspace in MATLAB.Similar results can be obtained in both ways.Signals considered are transient, sag, swell, interruption, harmonics, fluctuations and flicker for duration of 0.4 s.The coefficients plot as a function of scale and time and coefficients line are obtained in step-by-step In the context of continuous wavelet analysis, the evaluation of the flicker signal at a scale value of 64 reveals its maximum CWT coefficient, reaching a pivotal value of 0.1140.This peak coefficient serves as a critical indicator for discerning variations initiated in the voltage, offering insights into the dynamic changes within the signal and facilitating the visualization of deviations from the ideal waveform 42 .The choice of Morse, Morlet, and bump wavelets as mother wavelets adds depth to the analysis, each contributing unique characteristics to the exploration of power quality disturbance signals.These wavelets play a pivotal role in uncovering hidden patterns that might elude detection in the original signals 43,44 .The matrix dimensions of coefficients for all considered signals are contingent on the selected scale, with the scale range of 1:16:128 dictating the breadth of frequency representations.This comprehensive scaling approach allows for a detailed exploration of signals across a spectrum of frequencies, providing a foundation for nuanced analyses.Tables 1 and 2 further enrich the narrative; Table 1 meticulously delineates the energy values of coefficients obtained through the continuous wavelet transform at scales 1 and 64, offering a dual-scale perspective on high and low frequencies.Meanwhile, Table 2 introduces  www.nature.com/scientificreports/time, scale, and coefficient values on the respective axes.This visual representation at scales 1 and 64 unravels the intricate interplay between high and low-frequency components, emphasizing the inverse relationship between scale and frequency.The examination of power quality disturbance signals during their initiation and recovery phases reveals conspicuous deviations in the coefficients, providing crucial insights into the transient nature of these disturbances 45,46 .To unravel the intricacies of these signals, a comprehensive analysis employing Fourier transform, short-time Fourier transform, and continuous wavelet transform (CWT) is undertaken.Each of these transforms serves as a lens through which the signals are perceived in different domains, enriching the understanding of their multifaceted characteristics 47,48 .Notably, CWT is applied with continuous scales, signifying an inverse relationship with frequency 49 .This approach allows for the encapsulation of diverse energy levels within each scale, with the highest scale value of 64 strategically employed to extract low-frequency contents, while the lowest scale value of 1 adeptly captures high-frequency components.Consequently, the information about power quality disturbances is encapsulated as a dynamic interplay between low and high-frequency energy levels.The coefficients derived from CWT are meticulously plotted as a function of both scale and time, elucidating the temporal and frequency-specific variations.This methodology proves instrumental in unveiling hidden patterns that remain obscured in the original signals 50,51 .However, it is imperative to acknowledge that the computational demands of CWT analysis introduce redundancy, necessitating judicious considerations 52 .The analytical process is facilitated through both command-line functionality and the graphical interface of MATLAB, providing a robust platform for the identification of power quality disturbances using the insights derived from CWT 53,54 .

Discrete wavelet transform (DWT)
Discrete Wavelet Transform (DWT) emerges as a powerful tool for disentangling the intricate details within power quality disturbance signals 55,56 .Leveraging the concept of multiresolution analysis, DWT efficiently decomposes a signal into multi-resolution components, unraveling its diverse frequency components.Discrete wavelet transform is used for decomposing a signal into multi-resolution components and for detecting changes in signal waveforms 57 .The theory of multiresolution signal decomposition was proposed by Stephan Mallat and certain 58 important theorems were proved with description of mathematical modes in which are necessary for multiresolution representation termed as, "wavelet representation" for extracting information between successive resolutions.The decomposition process unfolds in a hierarchical fashion, initially splitting the signal into level one approximation and detail 59 .The iterative refinement continues, progressively delving deeper into the signal's nuances, until a sufficient level of information is captured 60 .The elegance of multiresolution analysis unfolds as the signal undergoes a sequential dissection, revealing its nuanced structure 61 .Initially, the signal is bifurcated into a level one approximation and detail.An iterative refinement process ensues, as the detail is disregarded, and the approximation is further scrutinized through the lens of a secondary multiresolution analysis 62 .This cascading refinement continues until a critical juncture is reached where the loss of information becomes perceptible.The quintessence of wavelet analysis lies in the identification of signal variations through this intricate multiresolution journey.The discrete wavelet transform (DWT) becomes the linchpin, orchestrating this process with finesse.It orchestrates a dual representation of the signal-low frequency encapsulated within the approximation and high frequency articulated through detail components 63,64 .In stark contrast to its continuous counterpart, DWT operates with optimal efficiency, eliminating redundancy while preserving the essential information mosaic.The overarching aim remains clear: applying the wavelet transform as a discerning lens to unravel the mysteries of power quality disturbances, decoding the nuanced features embedded within the signals 65 .This pursuit is augmented by the extraction of key attributes from the level 1 detail coefficients, encompassing the peak characteristics, variance, and skewness of level 7 approximations, alongside the mean deviation of level 6 details, as explicated in 66 .
It is mentioned in 67 that the property of multiresolution gives precise low and high frequency content information of the analyzed signal by using long and short windows.Figure 33 comprises of few wavelets (a) db1 (b) db2 to db10 (c) coif 1 to coif 5 (d) sym 2 to sym8 which are used as mother wavelets.The discrete wavelet transform is defined in Eq. ( 15) 6 , with complex conjugate of mother wavelet given by ψ * (t).
In Eq. ( 15), the discretized mother wavelet is given by Eq. ( 16)  68 .Any function in time domain is represented by discrete wavelet transform with scaling function as ϕ(t) and wavelet function as ψ(t) 6 is represented by Eq. ( 17).
The term k c j (k)2 j/2 ϕ 2 j t − k represents approximation and k d j (k)2 j/2 ψ 2 j t − k represents detail of the signal with j referring 'scaling parameter' and k 'shift parameter' .

DWT based Identification of PQ disturbances
Embarking on a meticulous dissection, power quality disturbance signals undergo a comprehensive analysis through a sophisticated five-level decomposition, leveraging the prowess of Daubechies 4 (db4) as the designated mother wavelet 69,70 .This intricate process involves the instantiation of daughter wavelets, aptly referred to as template functions, with their width defining the elusive scale.The multifaceted procedure unfolds through the tandem application of filtering and downsampling, the dynamic duo driving the dissection into quintessential components 71 .At the heart of this analytical symphony lies the extraction of linear combinations of wavelet functions, christened as wavelet coefficients 72 .This culmination not only marks the transformation of the signal but births a new realm-the wavelet transform 73 .The convolutional interplay with low and high pass filters ushers in a dichotomy of approximation and detail coefficients, each holding a unique key to the intricate tapestry of the signal's essence.To crystallize this revelation, the obtained signal undergoes a deliberate downsampling by a factor of two, culminating in a nuanced and distilled representation 74,75 .Navigating the intricate landscape of signal analysis, the Discrete Wavelet Transform (DWT) emerges as a beacon of precision, adept at discerning nuanced transitions within the signal.This methodical dissection unfolds over five levels, where the signal undergoes a metamorphosis, decomposing into a tapestry of multi-resolution components.The linchpin of this process lies in the intricate interplay of template functions-a consequence of the shifting and dilation of the chosen mother wavelet.These templates, resembling a symphony of patterns, are meticulously compared with the disturbances encoded within the signal.The extent of correlation serves as a compass, revealing the distinct fingerprint of each type of disturbance.Daubechies fourth-order wavelet (db4), showcased in the visual tableau of Fig. 41, emerges as the maestro in power quality analysis.Its selection is not arbitrary but rooted in the ' compactness and localization' properties, rendering it an ideal candidate for unraveling the complexities of disturbances 76 .A pivotal study 77 adds an extra layer of validation, drawing comparisons between the entropy values of approximations within disturbance signals and a reference sinusoidal signal-a testament to the robustness and reliability of the chosen methodology.
In the realm of signal analysis, the Discrete Wavelet Transform (DWT) stands out as a meticulous tool capable of discerning intricate transitions within signals 78 .Its remarkable ability to identify discontinuities is most pronounced at the initial level of detail.This intrinsic characteristic renders the DWT particularly adept at effectively identifying signals characterized by abrupt changes, overshadowing its efficacy in scenarios involving harmonics, fluctuations, and flicker, where alterations manifest more gradually.The lucidity of identification becomes notably conspicuous when scrutinizing signals associated with sag, swell, interruption, and transient phenomena 79 .Level 1 details, akin to a metaphorical magnifying lens, systematically unravel the complexities of these specific disturbances, furnishing a nuanced and exhaustive perspective crucial in the domain of power quality analysis 80 .
, 18, 19, 20, 21, 22, 23 and 24 show the analysis of all the PQ disturbance signals using STFT.The spectrogram is considered as STFT representation of the signals and STFT spectrum in all the figures represent a two-dimensional representation of frequency and time with varying amplitude indicated by common color bar in Fig. 16.

FlickerTable 2 .
www.nature.com/scientificreports/Insights about the continuous wavelet transform (CWT) coefficient matrix and reason for selection of discrete wavelet transform (DWT) over CWT • In the CWT coefficient matrix dimensions, each row of the matrix contains the CWT coefficients for one scale.• The column dimension of the matrix is equal to the length of the input signal.• There are 64 rows because the 'SCALES' input to CWT is 1:1:64, with 1 representing initial value, 1 represent- ing increment and 64 representing maximum value of scale used.• The length of different signals used in time domain is 2501 with input given in MATLAB as t = [0:0.0001:0.25].• Thus, the CWT coefficient matrix has 64 rows and 2501 columns.• Computation is more using continuous wavelet transform (CWT) and results in redundant information.• Compared to CWT, discrete wavelet transform (DWT) contains required amount of information without redundancy and requires less computation.Continuous wavelet transform based 3D plots of coefficients.

Table 1 .
Energy values of CWT coefficients for each disturbance.